import Store from '../store'
// router.js
import {RouterMount, createRouter} from 'uni-simple-router';

const Router = createRouter({
    platform: "h5",
    routes: [...ROUTES]
});
//全局路由前置守卫
Router.beforeEach((to, from, next) => {
    if (Store.getters["Auth/getIsGuest"]) {
        if (to.authType === "@" || !to.authType){
            // Tool.setCache('beforeLoginPath', to.path);
            next('/pages/site/Login')
        }
    } else {
        if (to.authType === "?"){
            next('/pages/site/Index')
        }
    }
    next();
});
// 全局路由后置守卫
Router.afterEach((to, from) => {})

export {
    Router,
    RouterMount
}
